package com.iseastar.guojiang.print.adapter;

import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shouhuobao.station.R;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterExt;

/**
 * Created by joker on 2017/7/26.
 */

public class BluetoothSettingAdapter extends BaseAdapterExt<BluetoothDevice> {

    public BluetoothSettingAdapter(ArrayList<BluetoothDevice> items, Activity context) {
        super(items, context);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (hasEmptyView()) {
            return super.getView(position, convertView, parent);
        }
        ViewHolder holder;
        if (convertView == null || convertView.getTag() == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_bluetoothsetting, parent, false);
            holder.deviceNameTV = (TextView) convertView.findViewById(R.id.devicename_TV);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        final BluetoothDevice item = items.get(position);
        holder.deviceNameTV.setText(item.getName());
        return convertView;
    }

    private class ViewHolder {
        TextView deviceNameTV;
    }
}
